<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>编辑</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <script type="text/javascript" th:src="@{/static/js/jquery-3.js}"></script>
    <script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>

    <style type="text/css">
        .layui-form-selectup dl{
            top:42px;
            bottom:unset;
        }
    </style>

</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改用户</legend>
</fieldset>

<div class="layui-form-item">
    <label class="layui-form-label">id&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${user.id}" type="text" name='id' id="id" readonly="readonly" lay-verify="required" lay-reqtext="用户昵称为必填项" placeholder="请输入用户昵称" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">用户昵称&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${user.nick}" type="text" name='nick' id="nick" readonly="readonly" lay-verify="required" lay-reqtext="用户昵称为必填项" placeholder="请输入用户昵称" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">邮箱&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${user.email}" type="text" name='email' id="email" readonly="readonly" lay-verify="required" lay-reqtext="用户名为必填项" placeholder="请输入用户名" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">头像&nbsp;:</label>
    <div class="layui-input-block">
        <img style="width: 50px; height: 50px" th:src="${user.lcon}"/>
        <!--<input th:value="${user.lcon}" type="text" name='lcon' id="lcon" readonly="readonly" lay-verify="required" lay-reqtext="" placeholder="请输入用户名" autocomplete="off"  style="width:500px;"   class="layui-input" >-->
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">性别&nbsp;:</label>
    <div class="layui-input-block">
        <select name="sex" id="sex" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${user.sex == 0}" value="0">男</option>
            <option th:selected="${user.sex == 1}" value="1">女</option>
            <option th:selected="${user.sex == 2}" value="2">未知</option>
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">注册时间&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${#dates.format(user.createdate,'yyyy-MM-dd')}" type="text" name='createdate' id="createdate" readonly="readonly" lay-verify="required" lay-reqtext="用户名为必填项" placeholder="请输入用户名" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">个性签名&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${user.sign}" type="text" name='sign' id="sign" readonly="readonly" lay-verify="required" lay-reqtext="用户名为必填项" placeholder="请输入用户名" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">状态&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="state" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${user.state == 0}" value="0">禁用</option>
            <option th:selected="${user.state == 1}" value="1">正常</option>
        </select>
    </div>
</div>


<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="editBtn">修改</button>
    </div>
</div>

<script>

    var basePath="/";

    layui.use(['form'],function () {
        var thisIndex = parent.layer.getFrameIndex(window.name);
        var form = layui.form;
        var parentLayer = parent.layer;
        form.on("submit(editBtn)",function () {
            var obj = {
                id:$("#id").val(),
                nick: $("#nick").val(),
                email: $("#email").val(),
                lcon:$("#lcon").val(),
                sex:$("#sex").val(),
                createdate:$("#createdate").val(),
                sign:$("#sign").val(),
                state: $("#state").val()

            };
            $.post(basePath+"user-update",obj,function (data) {
                if(data.success){
                    parentLayer.msg("修改成功",{
                        icon: 1,
                        time: 1000
                    });
                }else{
                    parentLayer.msg("修改失败",{
                        icon: 1,
                        time: 2000
                    });
                }
                parent.location.reload();
                parentLayer.close(thisIndex);
            },"json");

        })
    })

</script>

</body>
</html>